<ng-form name="form">
  <div ng-hide="input.args.length"><em>No {{type || 'command'}} set.</em></div>
  <div ng-show="input.args.length" as-sortable ng-model="input.args" class="command-args has-sort">
    <div class="row form-row-has-controls" ng-repeat="arg in input.args" as-sortable-item>
      <div class="form-group col-xs-12">
        <input type="text"
               ng-model="arg.value"
               ng-if="!arg.multiline"
               required
               class="form-control"
               autocorrect="off"
               autocapitalize="none"
               spellcheck="false">
        <textarea ng-model="arg.value"
                 ng-if="arg.multiline"
                 rows="5"
                 required
                 class="form-control"
                 autocorrect="off"
                 autocapitalize="none"
                 spellcheck="false">
        </textarea>
      </div>
      <div class="form-row-controls">
        <button
          class="sort-row"
          type="button"
          aria-hidden="true"
          as-sortable-item-handle>
          <span class="fa fa-bars"></span>
          <span class="sr-only">Move row</span>
        </button>
        <button
          class="btn-remove close delete-row"
          type="button"
          aria-hidden="true"
          ng-click="removeArg($index)">
          <span class="pficon pficon-close" aria-hidden="true"></span>
          <span class="sr-only">Delete row</span>
        </button>
      </div>
    </div>
  </div>
  <div class="form-group">
    <label class="sr-only" ng-attr-for="{{id}}-add-arg">
      <span ng-if="placeholder">{{placeholder}}</span>
      <span ng-if="!placeholder">Add argument</span>
    </label>
    <!-- Single-line entry -->
    <span ng-show="!multiline" class="input-group">
      <input type="text"
             ng-model="nextArg"
             name="nextArg"
             ng-attr-id="{{id}}-add-arg"
             on-enter="addArg()"
             ng-attr-placeholder="{{placeholder || 'Add argument'}}"
             class="form-control"
             autocorrect="off"
             autocapitalize="none"
             spellcheck="false">
      <span class="input-group-btn">
        <!-- Must be a link rather than a button so that enter submits the parent form when other
             fields are focused. Add an enter key handler for the input when focused using the
             on-enter directive. -->
        <a class="btn btn-default"
           href=""
           ng-click="addArg()"
           ng-disabled="!nextArg"
           ng-attr-aria-disabled="!nextArg"
           role="button">Add</a>
      </span>
    </span>
    <!-- Multiline entry -->
    <span ng-show="multiline">
      <textarea ng-model="nextArg"
                name="nextArg"
                rows="10"
                ng-attr-id="{{id}}-add-arg"
                ng-attr-placeholder="{{placeholder || 'Add argument'}}"
                class="form-control"
                autocorrect="off"
                autocapitalize="none"
                spellcheck="false">
      </textarea>
      <div class="mar-top-md">
        <a class="btn btn-default"
           href=""
           ng-click="addArg()"
           ng-disabled="!nextArg"
           ng-attr-aria-disabled="!nextArg"
           role="button">Add</a>
      </div>
    </span>
    <div class="help-block">
      <span ng-if="description">{{description}}</span>
      <span ng-if="!description">
        Enter the command to run inside the container. The command is considered successful if its
        exit code is 0. Drag and drop to reorder arguments.
      </span>
    </div>
  </div>
  <div class="mar-top-sm mar-bottom-md">
    <a href="" ng-click="multiline = !multiline">Switch to {{multiline ? 'Single-line' : 'Multiline'}} Editor</a>
    <span ng-show="input.args.length">
      <span class="action-divider">|</span>
      <a href="" ng-click="clear()" role="button">Clear {{ (type || 'Command') | upperFirst }}</a>
    </span>
  </div>
  <!-- Add a hidden input to help with form validation. -->
  <input type="hidden" name="command" ng-model="input.args" ng-required="isRequired">
  <div ng-if="form.command.$dirty && form.command.$error.required" class="has-error">
    <span class="help-block">A command is required.</span>
  </div>
</ng-form>
